package com.example.system.controller;


import com.example.common.AjaxResult;
import com.example.system.domain.SysUser;
import com.example.system.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    SysUserService sysUserService;

    @RequestMapping("/circuitList")
    public List<SysUser> circuitList(SysUser circuit){
        List<SysUser> list = sysUserService.selectUserList(circuit);
        return list;
    }
    @ResponseBody
    @RequestMapping("/login")
    public AjaxResult login(SysUser user){
        if(user.getUserName().isEmpty()){
            return  AjaxResult.error(500,"用户名不能为空");
        }
        if(user.getPassword().isEmpty()){
            return  AjaxResult.error(500,"密码不能为空");
        }
//        List<SysUser> list = sysUserService.login(user);
        return sysUserService.login(user);
    }

    //导出接口
    @RequestMapping("/selectUserByUserName")
    public AjaxResult export(@RequestParam String type) throws Exception {
        return AjaxResult.success("success",sysUserService.selectUserByUserName(type));
    }

}
